Skip to content

A problematic test showing interaction of boxing and inheritance #16415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Nov 25, 2022

Plus a small simplification in CheckCaptures

Plus a small simplification in CheckCaptures
@odersky odersky added the cc-experiment Intended to be merged with cc-experiment branch on origin label Nov 25, 2022
@odersky
Copy link
Contributor Author

odersky commented Nov 25, 2022

This test currently fails:

abstract class A[X]:
  def foo(x: X): X

class IO
class C
def test(io: {*} IO) =
  class B extends A[{io} C]:    // error, but should work
    override def foo(x: {io} C): {io} C = ???

with the error message

7 |  class B extends A[{io} C]:
  |        ^
  |class B needs to be abstract, since def foo(x: X): X in class A is not defined
  |(Note that
  | parameter X in def foo(x: X): X in class A does not match
  | parameter {io} C in override def foo(x: {io} C): {io} C in class B
  | )
*/

Arguably there should be a way to achieve such overridings. You can think of it as inserting a bridge method in B that implements the method in A by forwarding to the method in B and box-adapting argument and result. However, it seems that such a box adaptation could in general require some capability in B that was not required before. So this would need to be worked into the general capability propagation framework.

@odersky
Copy link
Contributor Author

odersky commented Jul 13, 2023

Looks like this test compiles now. I am adding the test to #18192 and am closing this one.

@odersky odersky closed this Jul 13, 2023
odersky added a commit to dotty-staging/dotty that referenced this pull request Jul 13, 2023
odersky added a commit to dotty-staging/dotty that referenced this pull request Jul 14, 2023
odersky added a commit to dotty-staging/dotty that referenced this pull request Jul 16, 2023
olhotak pushed a commit to dotty-staging/dotty that referenced this pull request Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cc-experiment Intended to be merged with cc-experiment branch on origin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant